package seekting.demo2017.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import seekting.demo2017.R;

/**
 * Created by seekting on 17-8-15.
 */

public class SvgActivity extends AppCompatActivity {

    private Thread mThread;
    private Handler mHandler;
    private HandlerThread mHandlerThread1;
    private HandlerThread mHandlerThread;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.svg_activity);
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread thread, Throwable ex) {
                Log.d("seekting", "SvgActivity.uncaughtException()" + thread, new NullPointerException());

            }
        });
        mHandlerThread = new HandlerThread("test");
        Log.d("seekting", "SvgActivity" + mHandlerThread.isAlive());
        mHandlerThread.start();
        Log.d("seekting", "SvgActivity" + mHandlerThread.isAlive());
        mHandlerThread1 = new HandlerThread("test1");
        mHandlerThread1.start();
        mHandler = new Handler(mHandlerThread.getLooper());
        Handler mHandler1 = new Handler(mHandlerThread1.getLooper());
        mHandler1.post(new Runnable() {
            @Override
            public void run() {
                if (true) {
                    throw new NullPointerException();
                }
            }
        });

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        Log.d("seekting", "SvgActivity.onBackPressed()" + mHandlerThread.isAlive());

        mHandler.post(new Runnable() {
            @Override
            public void run() {
                Log.d("seekting", "SvgActivity.run()" + "alive");
            }
        });
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d("seekting","SvgActivity.onRestart()");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d("seekting","SvgActivity.onStart()");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("seekting","SvgActivity.onResume()");
    }
}
